package com.cncoral.sunfuyi.jiankong;

import android.app.Activity;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

/**
 * Created by Sun.Fuyi on 2016/1/18.
 */
public class MainActivity extends Activity {
    private String ip = "http://www.indoorbuy.com/system";
    private WebView mWebView;
    private WebSettings settings;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        requestWindowFeature(Window.FEATURE_NO_TITLE);//隐藏标题
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);//设置全屏
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
    }

    private void initView() {
        mWebView = (WebView) findViewById(R.id.webview);
        settings = mWebView.getSettings();
        settings.setSupportZoom(true);

//支持javascript
        settings.setJavaScriptEnabled(true);
//自适应屏幕
        settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
        settings.setLoadWithOverviewMode(true);
        mWebView.loadUrl(ip);
        mWebView.setWebViewClient(new WebViewClient());

// 可以控制webView放大和缩小
        mWebView.getSettings().setBuiltInZoomControls(true);
// 设置自适应屏幕的方法
        mWebView.getSettings().setUseWideViewPort(true);
    }

   /* @Override
    protected void onResume() {
        *//**
         * 设置为横屏
         *//*
        if (getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        }
        super.onResume();
    }*/
}
